/********************************************************************
	filename: 	Line2D.h
	created:	2010/04/16
	author:		Xiuwei Chen

	purpose:	Definition of class 2D line

	All rights Reserved
*********************************************************************/

#pragma  once

#include "Const.h"
#include "Vector2D.h"
#include "Segment2D.h"

class GEOMETRY_EXPORT Line2D
{
public:
	/// <Summary>
	/// Zero of Line2D
	/// </Summary>
	const static Line2D Zero;

	/// <Summary>
	/// Expression of Line2D
	/// </Summary>
	double a, b, c;

	/// <Summary>
	/// default constructor
	/// </Summary>
	Line2D();
	
	/// <Summary>
	/// copy constructor
	/// </Summary>
	Line2D(const Line2D &line);

	/// <Summary>
	/// constructor
	/// </Summary>
	Line2D(const Point2D &p0, const Point2D &p1);

	/// <Summary>
	/// constructor
	/// </Summary>
	Line2D(double _a, double _b, double _c);

	/// <Summary>
	/// set value
	/// </Summary>
	void SetValue(double _a, double _b, double _c);

	/// <Summary>
	/// overload operation: assignment
	/// </Summary>
	Line2D & operator = (const Line2D &line);

	/// <Summary>
	/// overload operation: "=="
	/// </Summary>
	bool operator == (const Line2D &line) const;

	/// <Summary>
	/// overload operation: "!="
	/// </Summary>
	bool operator != (const Line2D &line) const;


	/// <Summary>
	/// Translation by 2D vector
	/// </Summary>
	void Translation(const Vector2D &v);

	/// <Summary>
	/// sqrt(a ^ 2 + b ^ 2)
	/// </Summary>
	double Norm() const;

	/// <Summary>
	/// (a ^ 2 + b ^ 2)
	/// </Summary>
	double Norm2() const;

	/// <Summary>
	/// Line Normalize
	/// </Summary>
	void Normalize();

	/// <Summary>
	/// get the line angle with the forward direction of X axis: [0, PI)
	/// </Summary>
	double Angle() const;

	/// <Summary>
	/// get horizontal vector of 2D line
	/// </Summary>
	Vector2D Horizontal(bool unit = false) const;

	/// <Summary>
	/// get vertical vector of 2D line
	/// </Summary>
	Vector2D Vertical(bool unit = false) const;

	/// <Summary>
	/// get the Perpendicular which pass by a point
	/// </Summary>
	Line2D Perpendicular(const Point2D &p) const;

	/// <Summary>
	/// rotate counter clockwise around a point (radian)
	/// </Summary>
	void Rotation(const Point2D &center, double angle);

	/// <Summary>
	/// get the value of line expression
	/// </Summary>
	double Evaluation(const Point2D &p) const;
};